﻿using System;
using System.Windows.Input;
using LokumClient.Commands;

namespace LokumClient.ViewModels
{
    public class MainViewModel : ViewModelBase
    {
        private readonly Action<bool> _showHideApp;
        private DateTime _updateDateTime;
        private string _status;
        private int _flatsCount;

        private ICommand _showHideMainWindowCommand;

        public MainViewModel(Action<bool> showHideApp)
        {
            _showHideApp = showHideApp;
            _updateDateTime = DateTime.Now;
        }

        public DateTime UpdateDateTime
        {
            get { return _updateDateTime; }
            set
            {
                //_updateDateTime = value;
                //OnPropertyChanged();
                SetProperty(ref _updateDateTime, value);
            }
        }

        public string Status
        {
            get { return _status; }
            set { SetProperty(ref _status, value); }
        }

        public int FlatsCount
        {
            get { return _flatsCount; }
            set { SetProperty(ref _flatsCount, value); }
        }

        public ICommand ShowHideMainWindowCommand
        {
            get
            {
                return _showHideMainWindowCommand ??
                       (_showHideMainWindowCommand = new RelayCommand(o =>
                       {
                           var isForceShow = Convert.ToBoolean(o);
                           _showHideApp(isForceShow);
                       }));
            }
        }
    }
}